package com.bnyy.medicalHousekeeper.moudle.message.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.bnyy.common.adapter.BaseNormalListAdapter;
import com.bnyy.medicalHousekeeper.DialogHelper;
import com.bnyy.medicalHousekeeper.R;
import com.bnyy.medicalHousekeeper.UserInfoManager;
import com.bnyy.message.bean.chat.ChatMessage;
import com.bnyy.message.bean.chat.message_data.NoticeLocationAuthorityMessage;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Author : 关炳鹏
 * Description :
 * Date : 2023/1/9
 **/
public class NoticeLocationAuthorityAdapter extends BaseNormalListAdapter<ChatMessage, NoticeLocationAuthorityAdapter.ViewHolder> {

    public NoticeLocationAuthorityAdapter(Context context) {
        super(context);
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new ViewHolder(inflater.inflate(R.layout.item_message_notice_location_authority, parent, false));
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        super.onBindViewHolder(holder, position);

//        ChatMessage chatMessage = getData(position);
//
//        NoticeLocationAuthorityMessage noticeLocationAuthorityMessage = (NoticeLocationAuthorityMessage) chatMessage.getMessageData();
//        holder.tvTitle.setText(noticeLocationAuthorityMessage.getTitle());
//
//        holder.tvTime.setText(new SimpleDateFormat("yyyy-MM-dd HH:mm").format(new Date(chatMessage.getTime())));
//        holder.tvContent.setText(chatMessage.getContent());
//
//        holder.root.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//
//                if (UserInfoManager.getInstance().findDeviceUserInfoByWearId(noticeLocationAuthorityMessage.getWear_id()) == null) {
//                    DialogHelper.showTipsDialog(mContext, "设备已解绑");
//                } else {
//                    LocationActivity.show(mContext, noticeLocationAuthorityMessage.getUser_id(), noticeLocationAuthorityMessage.getWear_id());
//                }
//            }
//        });
    }

    public static class ViewHolder extends BaseNormalListAdapter.ViewHolder {

        TextView tvTime;
        TextView tvContent;
        TextView tvTitle;

        public ViewHolder(@NonNull View itemView) {
            super(itemView);

            tvTime = itemView.findViewById(R.id.tv_time);
            tvContent = itemView.findViewById(R.id.tv_content);
            tvTitle = itemView.findViewById(R.id.tv_title);
        }
    }
}
